#include "mainwindow.h"

#include <QApplication>
#include <QDebug>
#include <QLabel>
#include <QLayout>
#include <QSizePolicy>

#include <pwd.h>
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>

//#include <kysdk/kysdk-system/libkysysinfo.h>

//#include <ukuistylehelper/ukuistylehelper.h>

char *kdk_system_get_hostVirtType()
{
    char *virtType = (char *)malloc(sizeof(char) * 65);
    // ASSERT_NOT_NULL(virtType, NULL);
#ifdef __linux__
    FILE *pipeLine = popen("systemd-detect-virt", "r"); // 建立流管道
    if (!pipeLine) {
        free(virtType);
        return NULL;
    }
    if (fgets(virtType, 64 * sizeof(char), pipeLine) == NULL) {
        free(virtType);
        pclose(pipeLine);
        return NULL;
    }
    pclose(pipeLine);
    // strstripspace(virtType);
    if (strcmp(virtType, "microsoft") == 0)
        strcpy(virtType, "hyper-v");
    else if (strcmp(virtType, "oracle") == 0)
        strcpy(virtType, "orcale virtualbox");
#endif
    return virtType;
}

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    MainWindow w;
    w.init();

    const char *ddd = kdk_system_get_hostVirtType();

    w.show();
    return a.exec();
}
